<?php
class delete_db extends CI_Model{

    public function __construct()
    {
        // Call the Model constructor
        $this->load->database();
    }
    
    public function delete_product($id)
    {
        $query = $this->db->query("DELETE 
                                   FROM sanpham
                                   WHERE ID = '$id'");
        $query = $this->db->query("DELETE 
                                   FROM thongsosp
                                   WHERE idSP = '$id'");
        $query = $this->db->query("DELETE 
                                   FROM gia
                                   WHERE idSP = '$id'");   
        $query = $this->db->query("DELETE 
                                   FROM mau
                                   WHERE idSP = '$id'");
        $query = $this->db->query("DELETE 
                                   FROM lenke
                                   WHERE idSP = '$id'"); 
        $query = $this->db->query("DELETE 
                                   FROM giamgia
                                   WHERE idSP = '$id'");
        
        
        $query = $this->db->query("DELETE 
                                   FROM hinhanh
                                   WHERE id IN ( SELECT idAnh
                                                   FROM anhlon
                                                   WHERE idSP = $id)");
        $query = $this->db->query("DELETE 
                                   FROM hinhanh
                                   WHERE id IN ( SELECT idAnh
                                                   FROM thumbnail
                                                   WHERE idSP = $id)");
        $query = $this->db->query("DELETE 
                                   FROM anhlon
                                   WHERE idSP = '$id'");
        $query = $this->db->query("DELETE 
                                   FROM thumbnail
                                   WHERE idSP = '$id'");
        $this->db->close();
    }
    
 }
 ?>